/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  8
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (0 -1 0);

boundaryField
{
    inlet
    {
        type            codedFixedValue;
        value           uniform (0 -1 0);
        name            codeinlet;
        code            #{
            const fvPatch& boundaryPatch = this->patch();

            vectorField U = boundaryPatch.Cf();
            vectorField u = boundaryPatch.Cf();

            forAll(boundaryPatch, faceI)
            {                        
            U[faceI] = vector(0, -1, 0);
            u[faceI] = 0.01*exp(-0.5)*vector(rand() % 2 - 1, rand() % 2 - 1, rand() % 2 - 1);
            U[faceI] = U[faceI]+u[faceI];
            if (U[faceI].y() > 0)
            {
                U[faceI].y() = -U[faceI].y();
            }
            }
            
            operator==(U+u);
        #};
    }

    outlet
    {
        type            zeroGradient;
    }

    wall
    {
        type            zeroGradient;
    }
}

// ************************************************************************* //
